package com.ijiuchuang.jc_localization.view.activity;

import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.ijiuchuang.jc_localization.R;
import com.ijiuchuang.jc_localization.base.BaseActivity;
import com.ijiuchuang.jc_localization.bean.entity.BleDevice;
import com.ijiuchuang.jc_localization.contract.tools.ToolsConnectionContract;
import com.ijiuchuang.jc_localization.contract.tools.ToolsGuardsContract;
import com.ijiuchuang.jc_localization.presenter.tools.ToolsConnectionPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ToolsConnectionActivity extends BaseActivity implements ToolsConnectionContract.View {

    public static final String TOOLS_CONNECTION_DEVICE = "ToolsConnectionActivity.bundle.device";
    @BindView(R.id.tools_connection_toolbar)
    Toolbar mToolbar;
    @BindView(R.id.tools_connection_fab)
    FloatingActionButton mFab;
    @BindView(R.id.tools_connection_coordinator)
    CoordinatorLayout mCoordinator;

    private ToolsConnectionContract.Presenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tools_connection);
        ButterKnife.bind(this);
        setSupportActionBar(mToolbar);
        mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        presenter = new ToolsConnectionPresenter(this, this);
        presenter.start();
    }

    @OnClick({R.id.tools_connection_fab})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tools_connection_fab:
                Snackbar.make(mCoordinator, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
                break;
        }
    }

    @Override
    public BleDevice getDevice() {
        Bundle bundle = getIntent().getExtras();
        BleDevice bleDevice = (BleDevice) bundle.getSerializable(TOOLS_CONNECTION_DEVICE);
        return bleDevice;
    }

    @Override
    public void setPresenter(ToolsConnectionContract.Presenter presenter) {
        this.presenter = presenter;
    }
}
